package com.basin.common.mybatisflex.config;

import com.basin.common.mybatisflex.base.BaseEntity;
import com.basin.common.mybatisflex.listener.InsertOrUpdateListener;
import com.mybatisflex.core.FlexGlobalConfig;
import com.mybatisflex.spring.boot.MyBatisFlexCustomizer;
import org.springframework.boot.autoconfigure.AutoConfiguration;

/**
 * @author: Sam ZHONG | sammy1997@aliyun.com
 * @date: 2025/4/6 21:06
 * @description:
 */
@AutoConfiguration
public class BasinMybatisFlexConfig implements MyBatisFlexCustomizer {
    @Override
    public void customize(FlexGlobalConfig flexGlobalConfig) {
        // 全局注册监听器
        InsertOrUpdateListener insertOrUpdateListener = new InsertOrUpdateListener();
        flexGlobalConfig.registerInsertListener(insertOrUpdateListener, BaseEntity.class);
        flexGlobalConfig.registerUpdateListener(insertOrUpdateListener, BaseEntity.class);
    }
}
